package util;

import java.awt.Image;
import java.util.Random;

import jgame.JGColor;
import jgame.JGObject;

public class ColorDeformer {

	private static final Random rand = new Random();
	private JGColor[][] colors;
	
	private int damageCount = 0;
	private int damageLimit;

	private int width;
	private int height;
	
	public ColorDeformer(int width, int height, int damageLimit){
		
		this.width = width;
		this.height = height;
		colors = new JGColor[width][height];
		this.damageLimit = damageLimit;
	}
	
	public void hit(int damage){
		damageCount += damage;
		int wPick = rand.nextInt(width);
		int hPick = rand.nextInt(height);
		
		int r = rand.nextInt(256);
		int b = rand.nextInt(256);
		int g = rand.nextInt(256);
		int a = rand.nextInt(256);
		
		if (colors[wPick][hPick] == null){
			colors[wPick][hPick] = new JGColor(r,g,b,a);
		} else {
			JGColor col = colors[wPick][hPick];
			col.r = col.r + rand.nextInt(256-col.r);
			col.g = col.g + rand.nextInt(256-col.g);
			col.b = col.b + rand.nextInt(256-col.b);
			col.alpha = col.alpha + rand.nextInt(256-col.alpha);
		}
		
	}
	
	public JGColor[][] getColors(){
		return colors;
		
	}
	
	public Image getImage(){
		return null;
	}
	
}
